package github.leavesczy.reactivehttpsamples.adapter

import android.content.Context
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.chad.library.adapter4.BaseQuickAdapter
import github.leavesczy.reactivehttpsamples.core.mode.ResulData
import github.leavesczy.reactivehttpsamples.databinding.AdapterResultDetailItemBinding

class BridgeResultDetailAdapter : BaseQuickAdapter<ResulData, BridgeResultDetailAdapter.VH>(){

    class VH(val bind: AdapterResultDetailItemBinding) : RecyclerView.ViewHolder(bind.root)
    init {

    }

    override fun onCreateViewHolder(
        context: Context,
        parent: ViewGroup,
        viewType: Int
    ): BridgeResultDetailAdapter.VH {
        val inflate = AdapterResultDetailItemBinding.inflate(LayoutInflater.from(context), parent, false)
        return VH(inflate)
    }

    override fun onBindViewHolder(holder: VH, position: Int, item: ResulData?) {
        if(position==0){
            holder.bind.tvFieldOne.text="振型阶数"
            holder.bind.tvFieldTwo.text="固有频率(Hz)"
            holder.bind.tvFieldThird.text="阻尼比 (%)"
            holder.bind.tvFieldFour.text="模态质量(t)"
        }else{
            val itemNew=getItem(position-1)
            holder.bind.tvFieldOne.text=itemNew?.zxjs
            holder.bind.tvFieldTwo.text=itemNew?.gypl
            holder.bind.tvFieldThird.text=itemNew?.zxznb
            holder.bind.tvFieldFour.text=itemNew?.mtzl
        }


    }



    override fun getItemCount(items: List<ResulData>): Int {
        return super.getItemCount(items)+1
    }


}


